package com.jthinker.blog.web.controller.admin.common;

import com.jthinker.blog.bean.entity.Button;
import com.jthinker.blog.bean.enu.SortOrder;
import com.jthinker.blog.service.ButtonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * User: Gang Chen
 * Date: 2015/6/28 14:32
 */
@Controller
@RequestMapping("/common")
public class CommonController extends BaseController
{
    @Autowired
    private ButtonService buttonService;

    @RequestMapping("/getButtons")
    @ResponseBody
    public List<Button> getButtons(String alias)
    {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("alias", alias);
        return buttonService.list("from Button where menuAlias=:alias", -1, -1, "sort", SortOrder.ASC.toString(), params);
    }
}
